{include file="public/header" /}
<body>
<div class="x-body layui-anim" style="padding-top: 0">
    <form action="{:url('businessApply/addSave')}" class="layui-form" id="form">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">基本信息</li>
                <li>营业执照</li>
                <li>银行信息</li>
            </ul>
            <div class="layui-tab-content" style="height: 100px;">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label" label-required>申请会员</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="uid" id="uid" value="" required>
                            <input type="text" id="choose" name="name" value="" autocomplete="off" placeholder="输入姓名、编号、手机号筛选" class="layui-input" lay-verify="required" lay-reqtext="请选择会员">
                            <div id="mTable_wrap_choose" class="layui-anim layui-anim-scale m-table" style="bottom: auto; display: none;">
                                <div class="search-triangle"></div>
                                <table class="layui-table" id="mTable_choose" lay-filter="mTable_choose"></table>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">店铺类型</label>
                                <div class="layui-input-inline">
                                    <input type="radio" name="type" lay-filter="businessType" value="1" title="线上" checked>
                                    <input type="radio" name="type" lay-filter="businessType" value="2" title="线下">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">店铺名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="title" value="" class="layui-input" lay-verify="required" lay-reqtext="请填写店铺名称">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item ">
                        <label class="layui-form-label">店铺Logo</label>
                        <div class="layui-input-block">
                            <div class="layui-tab-item layui-show" style="width: 260px;">
                                <div class="layui-upload-drag uploadImage">
                                    <i class="layui-icon"></i>
                                    <p>点击上传，或将文件拖拽到此处</p>
                                    <div>
                                        <hr>
                                        <img src="" class="layui-upload-img showImage" alt="上传成功后渲染" style="max-width: 100%">
                                        <input type="hidden" name="logo" value="" class="inpImage" lay-verify="required" lay-reqtext="请上传logo" />
                                    </div>
                                </div>
                                <input class="layui-upload-file" type="file" accept="" name="file">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item ">
                        <label class="layui-form-label">店铺封面</label>
                        <div class="layui-input-block">
                            <div class="layui-tab-item layui-show" style="width: 260px;">
                                <div class="layui-upload-drag uploadImage">
                                    <i class="layui-icon"></i>
                                    <p>点击上传，或将文件拖拽到此处</p>
                                    <div>
                                        <hr>
                                        <img src="" class="layui-upload-img showImage" alt="上传成功后渲染" style="max-width: 100%">
                                        <input type="hidden" name="cover" value="" class="inpImage" lay-verify="required" lay-reqtext="请上传封面"/>
                                    </div>
                                </div>
                                <input class="layui-upload-file" type="file" accept="" name="file">
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">联系人</label>
                                <div class="layui-input-block">
                                    <input type="text" name="contacts" value="" class="layui-input" lay-verify="required" lay-reqtext="请填写联系人">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">手机号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="mobile" value="" class="layui-input"  lay-verify="required" lay-reqtext="请填写手机号">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">客服电话</label>
                                <div class="layui-input-block">
                                    <input type="text" name="customer_tel" value="" class="layui-input" lay-verify="required" lay-reqtext="请填写客服电话">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row" id="district_id" style="display: none">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label">店铺地区</label>
                                <div class="layui-inline sunSelect" data-url="{:url('order/getArea')}" data-value="code" data-name="title">
                                    <div class="layui-input-inline">
                                        <select name="province_id" data-name="省" data-level="1" data-id="" lay-filter="sunSelect"></select>
                                    </div>
                                    <div class="layui-input-inline">
                                        <select name="city_id" data-name="市" data-level="2" data-id="" lay-filter="sunSelect"></select>
                                    </div>
                                    <div class="layui-input-inline">
                                        <select name="district_id" data-name="区/县" data-level="3" data-id="" lay-filter="sunSelect"></select>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row" id="address_details" style="display: none">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">详细地址</label>
                                <div class="layui-input-block">
                                    <input type="text" name="address_details" value="" class="layui-input">
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="layui-tab-item">
                    <div class="layui-form-item " style="display: flex;">
                        <div>
                            <label class="layui-form-label">营业执照</label>
                            <div class="layui-input-block">
                                <input class="layui-upload-file" type="file" name="file">
                            </div>
                        </div>
                        <div class="uploadsPrev">
                            <ul class="layui-upload-list uploadsBtn" imgClass="randUploadImage" inpName="license[]">
                                <li class="w_imgCon">
                                    <img src="/static/admin/images/upload_img.svg">
                                </li>
                            </ul>
                            <ul class="layui-upload-list showImages">

                            </ul>
                        </div>
                    </div>
                </div>
                <div class="layui-tab-item">
                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label">银行名称</label>
                                <div class="layui-input-block">
                                    <select name="bank_name" lay-verify="required">
                                        {foreach name="bank" item="vo"}
                                        <option value="{$vo.title}">{$vo.title}</option>
                                        {/foreach}
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">开户行</label>
                                <div class="layui-input-block">
                                    <input type="text" name="bank_open" value="" class="layui-input">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">银行户名</label>
                                <div class="layui-input-block">
                                    <input type="text" name="bank_account" value="" class="layui-input">
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-row">
                        <div class="layui-col-xs8">
                            <div class="layui-form-item">
                                <label class="layui-form-label label-required">银行卡号</label>
                                <div class="layui-input-block">
                                    <input type="text" name="bank_number" value="" class="layui-input" >
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                <div class="layui-footer" style="left: 0;">
                    <a class="layui-btn" lay-filter="saveApply" lay-submit formObj="#form">保存</a>
                </div>
            </div>
        </div>
    </form>
</div>
</body>
{include file="public/footer" /}
<script>
    layui.use(['form', 'table', 'form'], function () {
        table = layui.table;
        mTable_wrap_choose = $('#mTable_wrap_choose');
        form = layui.form;
        $("#choose").on("input", function (e) {
            var value = e.delegateTarget.value;
            if (!value) {
                mTable_wrap_choose.hide();
                return false;
            }
            table.render({
                elem: '#mTable_choose'
                , id: 'mTable_choose'
                , url: '{:url("businessApply/selectUser")}?val=' + value + '&type=get'
                , even: true
                , size: 'sm'
                , cols: [[
                    {field: 'id', title: 'ID'}
                    , {field: 'nickname', title: '昵称'}
                    , {field: 'code', title: '编号'}
                    , {field: 'mobile', title: '手机号'}
                ]]
                , page: true
            });
            mTable_wrap_choose.show();
        });

        form.on('radio(businessType)', function (data) {
            if (data.value == 1) {
                $('#district_id').hide();
                $('#address_details').hide();
            } else {
                $('#district_id').show();
                $('#address_details').show();
            }
        });

        //触发行单击事件
        table.on('row(mTable_choose)', function (obj) {
            if (!obj.data.id) return false;
            /*if (obj.data.syn_level<3){
                layer.msg('会员级别不符，无权申请商家');
                return false;
            }*/
            mTable_wrap_choose.hide();
            $("#code").val(obj.data.code);
            $("#id").val(obj.data.id);
            $("#uid").val(obj.data.id);
            $("#choose").val(obj.data.nickname + ' - ' + obj.data.code + ' - ' + obj.data.mobile);
        });


        //监听表单提交
        form.on('submit(saveApply)', function (data) {

            layer.load();
            var btn = $(this);
            btn.attr('disabled', true);
            formObj = $($(this).attr('formObj'));
            console.log(data);
            url = formObj.attr('action');
            $.ajax({
                type: 'POST',
                url: url,
                data: formObj.serialize(),
                dataType: "json",
                success: function (data) {
                    layer.closeAll();
                    if (data.code == 1) {
                        notify.success(data.msg, 1500, function () {
                            window.location.reload();
                        });
                    } else {
                        notify.error(data.msg);
                        btn.removeAttr('disabled');
                    }
                },
                error(e) {
                    layer.closeAll();
                    btn.removeAttr('disabled');
                }
            });
            return false;
        })


    });
</script>
</html>